
  public class ListNode {
        int val;
        ListNode next;
        ListNode() {}
        ListNode(int val) { this.val = val; }
        ListNode(int val, ListNode next) { this.val = val; this.next = next; }
}
class Solution {
    public void reorderList(ListNode head) {
        //if(head == null){
        //    return null;
        //}

        ListNode slow = head;
        ListNode fast = head;
        //1.快慢指针
        while(fast != null && fast.next != null){
            slow = slow.next;
            fast = fast.next.next;
        }

        //2.回文反转链表
        ListNode pos = slow;
        ListNode cur = slow.next;
        while(cur != null){
            ListNode curNext = cur.next;
            cur.next = slow;
            slow = cur;
            cur = curNext;
        }
        pos.next = null;



        //3.创建傀儡节点交换链表
        ListNode newHead = new ListNode(-1);
        cur = newHead;
        while(slow.next != null){
            cur.next = head;
            cur = head;
            head = head.next;
            cur.next = slow;
            cur = slow;
            slow = slow.next;
        }
        cur.next = head;
        //return newHead.next;
    }
}